package tomcat;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;

public class Connector {
    private ExecutorService threadPool;

    public Connector(ExecutorService threadPool) {
        this.threadPool = threadPool;
    }

    public void start() {
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(9527);
            while (true) {
                Socket socket = serverSocket.accept();
                Runnable runnable = new RequestHandler(socket);
                threadPool.execute(runnable);
            }
        } catch (IOException e) {
            // log error
        }
    }
}
